package com.example.testdemo.designModel;

/**
 * 单例模式-----饿汉式   线程安全
 */
public class SinglonOne {

    public  static  SinglonOne  instance=new SinglonOne();
    public  SinglonOne(){
        System.out.println("==========构造方法");
    }

    public  static  SinglonOne  getInstance(){
        return  instance;
    }
}

class  TestDemo{
    public static void main(String[] args) {

         SinglonOne s1=SinglonOne.getInstance();
         SinglonOne s2=SinglonOne.getInstance();

        System.out.println(s1==s2);
    }
}
